package com.wuyou.securitydemo.component;

import com.wuyou.securitydemo.userdetails.CustomizedUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * CustomizedUserDetailsService
 *
 * @Date 2025/4/9 10:55
 * @Author 无忧
 */
@Slf4j
@Service
public class CustomizedUserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        log.info("loadUserByUseranme -> " + username);


        return new CustomizedUser(1L, 1L, username, passwordEncoder.encode("Cy123456."), "mobile", true,
                true, true, true,
                Collections.emptyList(), "displayName", Collections.emptyList());
    }
}
